////////////////////////////////////////////////////////////////////////////
//
//  Crytek Engine Source File.
//  Copyright (C), Crytek Studios, 2002.
// -------------------------------------------------------------------------
//  File name:   trackviewundo.h
//  Version:     v1.00
//  Created:     30/8/2002 by Timur.
//  Compilers:   Visual Studio.NET
//  Description: 
// -------------------------------------------------------------------------
//  History:
//
////////////////////////////////////////////////////////////////////////////

#ifndef __trackviewundo_h__
#define __trackviewundo_h__

#if _MSC_VER > 1000
#pragma once
#endif

struct IAnimTrack;
struct IAnimNode;

/** Used for undo objects that operate on tracks
*/
class CAbstractUndoTrackObject : public IUndoObject
{
protected:
	CAbstractUndoTrackObject( IAnimSequence *pSequence );

	typedef std::vector<int> TTrackPath;

	TTrackPath SaveTrackPath( IAnimTrack *pTrack );
	IAnimTrack *GetTrackFromSavedPath( TTrackPath &path );

	IAnimSequence *GetSequence();

	CString m_sequenceName;
};

/** Undo object stored when track is modified.
*/
class CUndoTrackObject : public CAbstractUndoTrackObject
{
public:
	CUndoTrackObject( IAnimTrack *pTrack, IAnimSequence* pSequence );
protected:
	virtual int GetSize() { return sizeof(*this); }
	virtual const char* GetDescription() { return "Track Modify"; };

	virtual void Undo( bool bUndo );
	virtual void Redo();
private:
	std::vector<int> m_pathToTrack;
	XmlNodeRef m_undo;
	XmlNodeRef m_redo;
};

/** Undo for adding a sequence group 
*/
class CUndoAnimSequenceGroupAdd : public IUndoObject
{
public:
	CUndoAnimSequenceGroupAdd( IAnimSequenceGroup *pGroup );
protected:
	virtual int GetSize() { return sizeof(*this); }
	virtual const char* GetDescription() { return "SequenceGroup Add"; };

	virtual void Undo( bool bUndo );
	virtual void Redo();

private:
	CString m_groupName;
	XmlNodeRef m_undo;
	XmlNodeRef m_redo;
};

/** Undo for renaming a sequence group 
*/
class CUndoAnimSequenceGroupRename : public IUndoObject
{
public:
	CUndoAnimSequenceGroupRename( IAnimSequenceGroup *pGroup );
protected:
	virtual int GetSize() { return sizeof(*this); }
	virtual const char* GetDescription() { return "SequenceGroup Rename"; };

	virtual void Undo( bool bUndo );
	virtual void Redo();

private:
	TSmartPtr<IAnimSequenceGroup> m_pGroup;
	CString m_undoName;
	CString m_redoName;
};

/** Undo for reparenting a sequence group 
*/
class CUndoAnimSequenceGroupReparent : public IUndoObject
{
public:
	CUndoAnimSequenceGroupReparent( IAnimSequenceGroup *pGroup );
protected:
	virtual int GetSize() { return sizeof(*this); }
	virtual const char* GetDescription() { return "SequenceGroup Reparent"; };

	virtual void Undo( bool bUndo );
	virtual void Redo();

private:
	TSmartPtr<IAnimSequenceGroup> m_pGroup;
	TSmartPtr<IAnimSequenceGroup> m_undoParent;
	TSmartPtr<IAnimSequenceGroup> m_redoParent;
};

/** Undo for deleting a sequence group
*/
class CUndoAnimSequenceGroupDelete : public IUndoObject
{
public:
	CUndoAnimSequenceGroupDelete( IAnimSequenceGroup *pGroup );
protected:
	virtual int GetSize() { return sizeof(*this); };
	virtual const char* GetDescription() { return "SequenceGroup Delete"; };

	virtual void Undo( bool bUndo );
	virtual void Redo();

private:
	TSmartPtr<IAnimSequenceGroup> m_pGroup;
	XmlNodeRef m_undo;
};

/** Undo object stored when sequence is modified.
*/
class CUndoAnimSequenceObject : public IUndoObject
{
public:
	CUndoAnimSequenceObject( IAnimSequence *seq );
protected:
	virtual int GetSize() { return sizeof(*this); }
	virtual const char* GetDescription() { return "Sequence Modify"; };

	virtual void Undo( bool bUndo );
	virtual void Redo();

private:
	TSmartPtr<IAnimSequence> m_pSequence;
	CString m_sequenceName;
	XmlNodeRef m_undo;
	XmlNodeRef m_redo;

	void ReloadLightEntities();
};


#endif // __trackviewundo_h__
